package com.shqcjd.sinopecdemomobile.ui.adapter;

import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shqcjd.sinopecdemomobile.R;
import com.shqcjd.sinopecdemomobile.model.pojo.AppOperationGuideMode;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by sy on 2019/5/9.
 */

public class TipWizardListAdapter extends BaseQuickAdapter<AppOperationGuideMode.ItemsBean, TipWizardListAdapter.ViewHolder> {

    private RequestOptions options;

    public TipWizardListAdapter() {
        super(R.layout.item_tip_wizard_list);

        options = new RequestOptions()
                .placeholder(R.mipmap.ic_default_small)    //加载成功之前占位图
                .error(R.mipmap.ic_default_small)    //加载错误之后的错误图
//                .override(109,68)	//指定图片的尺寸
                .centerCrop();//指定图片的缩
    }

    @Override
    protected void convert(TipWizardListAdapter.ViewHolder helper, AppOperationGuideMode.ItemsBean item) {

        helper.addOnClickListener(R.id.tv_start_btn);
        helper.addOnClickListener(R.id.fl_generate_btn);
        helper.addOnClickListener(R.id.tv_file_btn);

        helper.tv_start_btn.setText(item.guideTypeName);
        helper.factoryName.setText(item.manufacturer);
        helper.deviceName.setText(item.projectName);
        helper.goodCount.setText(item.goodTimes + "");
        Glide.with(mContext)
                .load(item.img)
                .apply(options)
                .into(helper.img);
    }

    class ViewHolder extends BaseViewHolder {
        @BindView(R.id.tv_start_btn)
        TextView tv_start_btn;
        @BindView(R.id.fl_generate_btn)
        FrameLayout fl_generate_btn;
        @BindView(R.id.set_name)
        TextView deviceName;
        @BindView(R.id.good_count)
        TextView goodCount;
        @BindView(R.id.tv_mfr)
        TextView factoryName;
        @BindView(R.id.iv_img)
        ImageView img;
        @BindView(R.id.tv_file_btn)
        TextView tv_file_btn;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }

}
